import 'package:flutter/material.dart';

class SampleAppbarWidget extends StatelessWidget {
  const SampleAppbarWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: _SampleAppbarWidget(),
    );
  }
}

class _SampleAppbarWidget extends StatefulWidget {
  const _SampleAppbarWidget({Key? key}) : super(key: key);

  @override
  __SampleAppbarWidgetState createState() => __SampleAppbarWidgetState();
}

class __SampleAppbarWidgetState extends State<_SampleAppbarWidget> with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(length: 5, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();

    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        // 标题层中
        automaticallyImplyLeading: false,
        // 不自动设置控件
        leading: BackButton(),
        title: Text("老孟"),
        actions: [
          IconButton(onPressed: () {}, icon: Icon(Icons.menu)),
          IconButton(onPressed: () {}, icon: Icon(Icons.add))
        ],
        bottom: TabBar(
          tabs: [Text('语文'), Text('数学'), Text('英语'), Text('历史'), Text('地理')],
          controller: _tabController,
        ),
        elevation: 10,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
        backgroundColor: Colors.red,
      ),
      body: Column(
        children: [
          RaisedButton(
            child: Text("界面跳转"),
            onPressed: () {
              // 界面跳转
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return Scaffold(
                  appBar: AppBar(
                    title: Text("老孟-1"),
                  ),
                );
              }));
            },
          ),
        ],
      ),
    );
  }
}
